
<form class="layui-form layui-form-pamel" name="form1" id="form1" method="post">
    <div class="searchbox demoTable" id="searchbox">

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">表名称：</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" maxlength="50" name="tableName" id="tableName" placeholder="请输入表名称"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">表描述：</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" maxlength="50" name="tableComment" id="tableComment" placeholder="请输入表描述"/>
                </div>
            </div>
            <input type="button" value="查询" onclick="$.table.search()" class="layui-btn layui-btn-red"/>
        </div>
    </div>
</form>

<div style="overflow:auto;width: 100%;padding-bottom: 20px;">
    <table id="simple-table" class="layui-table" lay-filter="simple-table">
    </table>
    <script type="text/html" id="barTable">
        <a class="layui-icon colored7764" lay-event="previewFlag" title="预览">预览</a>
        <a class="layui-icon colored7764" lay-event="editFlag" title="编辑">编辑</a>
        <a class="layui-icon colored7764" lay-event="delFlag" title="删除">删除</a>
        <a class="layui-icon colored7764" lay-event="codeFlag" title="生成代码">生成代码</a>
    </script>

    <script type="text/html" id="toolbarTable">
        <div class="layui-inline" title="添加" lay-event="addFlag"><i class="layui-icon layui-icon-add-circle"></i></div>
        <div class="layui-inline" title="导出" lay-event="exportExcel"><i class="layui-icon layui-icon-export"></i></div>
        <div class="layui-inline" title="下载模板" lay-event="importTemplate"><i class="layui-icon layui-icon-download-circle"></i></div>
        <div class="layui-inline" title="上传" lay-event="exportExcel"><i class="layui-icon layui-icon-upload"></i></div>
    </script>
</div>

<script type="text/javascript">

    var options = {
        id: 'simple-table',
        url:'${basePath}tool/getTablelist',
        javaField:'tableId',    //主键
        addUrl:'${basePath}tool/importTable',   //添加
        deleteUrl:'${basePath}tool/deleteTable',    //删除
        editUrl:'${basePath}tool/editTable?tableId=',   //编辑
        exportUrl:'${basePath}tool/exportTablelist',    //导出
        importTemplate:'${basePath}tool/exportTablelist',   //下载导入模板
        importTemplateUrl:'${basePath}tool/exportTablelist',    //导入
        addFull: false, //弹出框最大化
        editFull: true, //弹出框最大化
        toolbar: '#toolbarTable',  //开启工具栏
        modalName:'业务表',
        cols: [[
            {field:'tableId', title: '编号'}
            ,{field:'tableName', title: '表名称'}
            ,{field:'tableComment', title: '表描述'}
            ,{field:'className', title: '实体类名称'}
            ,{field:'createTime', title: '创建时间'}
            ,{field:'updateTime', title: '更新时间'}
            ,{title: '操作' ,width:200, align:'center', toolbar: '#barTable'}
        ]],
        page: true
    };

    var init = $.table.init(options);

    function codeFlag(data) {
        layer.confirm('真的生成<span style="color: #9f191f">'+data.tableName+'</span>表代码吗?', function(index){
            window.open("${basePath}tool/createCode?tableName=" + data.tableName);
            layer.close(index)
        });
    }

</script>
